package com.sams.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sams.entity.Leader;
import com.sams.entity.LeaderExample;
import com.sams.entity.LeaderExample.Criteria;
import com.sams.mapper.LeaderMapper;
import com.sams.service.LeaderService;

@Service
public class LeaderServiceImpl implements LeaderService{
	@Autowired
	private LeaderMapper mapper;

	//领导信息添加
	public int add(Leader leader) {
		
		return mapper.insert(leader);
	}

	//领导信息修改
	public int update(Leader leader) {
		
		return mapper.updateByPrimaryKey(leader);
	}

	//领导信息删除
	public int delete(int id) {
		return mapper.deleteByPrimaryKey(id);
	}

	

	

	//分页查询
	public PageInfo<Leader> listLeader(int currentPage) {
		PageHelper.startPage(currentPage, 7);   
		
		  LeaderExample example = new LeaderExample();
		 Criteria createCriteria = example.createCriteria();
		 
		  //设置条件  xue
		 //createCriteria.andIdEqualTo(1);
		 
		// System.out.println("====="+mapper);
		List<Leader> list =  mapper.selectByExample(example);
		
		
		PageInfo<Leader> pageInfo = new PageInfo<Leader>(list);
		//System.out.println("当前页："+pageInfo.getPageNum());
		//System.out.println("总记录数："+pageInfo.getPageSize());
		//System.out.println(pageInfo);
		 
		return pageInfo;
	}


}
